<?php

namespace app\index\controller;

use app\index\model\Htuser_htrole;
use think\Controller;
use think\Db;
use think\Request;

class Htrole extends Controller
{
    /**
     * 显示资源列表
     *
     * @return \think\Response
     */
    public function index()
    {
        config('default_return_type','json');
        return \app\index\model\Htrole::all();
    }
    function edit($id){
        config('default_return_type','json');
        return \app\index\model\Htrole::get($id);
    }


    public function update(Request $request, $id)
    {
        config('default_return_type','json');
        $user = input();
        if (empty($user['htrole_id'])){
            return['status'=>false,'message'=>"传值有误！"];
        }
        $result = Db::name('htuser_htrole')
            ->where('htuser_id',$id)
            ->update(['htrole_id' => $user['htrole_id']]);
        if ($result){
            return['status'=>true,'message'=>"修改成功！"];
        }else{
            return['status'=>false,'message'=>"修改失败！"];
        }
    }
}
